#include <stdio.h>

#include "encoder_task.h"
#include "buzzer.h"

#include "ohos_init.h"
#include "cmsis_os2.h"

extern encoder_task_data_t encoder_task_data;

void high_speed_task(void *arg)
{
    (void) arg;
    while(1)
    {
        if(encoder_task_data.buzzer_state == 1)
        {
            buzzer_on_low2();
            osDelay(10);
            buzzer_off();
            encoder_task_data.buzzer_state = 0;
        }
        WatchDogKick();
        osDelay(20);   //0.2s
    }
}

void high_speed_task_creat(void)
{
    osThreadAttr_t attr;

    attr.name       = "high_speed_task";
    attr.attr_bits  = 0U;
    attr.cb_mem     = NULL;
    attr.cb_size    = 0U;
    attr.stack_mem  = NULL;
    attr.stack_size = 2048;
    attr.priority   = osPriorityNormal2;

    if (osThreadNew(high_speed_task, NULL, &attr) == NULL)
    {
        printf("[high_speed_task_creat] Falied to create high_speed_task!\n");
    }
}

APP_FEATURE_INIT(high_speed_task_creat);